﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FlashLinkImage.ascx.cs" Inherits="Rison.Web.ascx.FlashLinkImage" %>
<style type="text/css">
    .flashAIndex
    {
    	width:22px;
    	height:12px;
    	line-height:12px;
    	margin-right:3px;
    	display:block;
    	float:left;
    	color:#f9fbfa;
    	font-family:Arial,Helvetica,sans-serif;
        font-size:10px;
    	cursor:pointer;
        text-align:center; 
    	text-decoration:none; 
    	background-color:#2f2d2e;
    }
    .flashAIndexCurrent
    {
    	width:22px;
    	height:12px;
    	line-height:12px;
    	margin-right:3px;
    	display:block;
    	float:left;
    	color:#2d0400;
    	font-family:Arial,Helvetica,sans-serif;
        font-size:10px;
    	cursor:pointer;
        text-align:center; 
    	text-decoration:none; 
    	background-color:#ffc906;
    }
    #idPicShow img {
	    width:300px;
	    height:228px;
	    background-color:#b4bdc4;
	    text-align :center ;	    
	    cursor:pointer ;
	    border:0px;
    }
    #idPicText {
        background:#eee;
        line-height:25px;
        text-align:center;
        font-weight:bold;
        width:267px;
        white-space:nowrap;
        overflow:hidden;
        font-size:12px;
    }
    #idPicText a {
        text-decoration:none;
        color:#333;
    }
    #idPicList img {
        cursor:pointer;
        width:65px;
        height:50px;
        filter:alpha(opacity=50);
        -moz-opacity: .5;
        opacity: .5;
        border:0;
        margin:10px;
    }
    #idPicList img.on {
        filter:alpha(opacity=100);
        -moz-opacity: 1;
        opacity: 1;
    }
</style>

<script type="text/javascript">
var isIE = (document.all) ? true : false;

var $ = function (id) { return "string" == typeof id ? document.getElementById(id) : id; };

var Class = {
    create: function() {
        return function() { this.initialize.apply(this, arguments); }
    }
}

Object.extend = function(destination, source) 
{
    for (var property in source) 
    {
        destination[property] = source[property];
    }
    return destination;
}

//ie only
var TransView = Class.create();

TransView.prototype = {
    initialize: function(arrList, idShow, idList, idText, options) 
    {
        if(!arrList || arrList.length == 0) return;
        
        var oThis = this, oShow = $(idShow), oList = $(idList), oText = $(idText), img = document.createElement("img"), a = document.createElement("a");

        //初始化显示区域javascript:;
        img.src = ""; a.target = "_blank"; if(isIE){ img.style.filter = "revealTrans(duration=1)"; };
        img.id="imgFlash";
        
        a.appendChild(img); oShow.appendChild(a);

        this._oList = oList;
        this._oText = oText;
        this._list = arrList;
        this._img = img;
        this._a = a;
        this._timer = null;
        this._index = -1;
        
        this.SetOptions(options);
        
        this.Time = Math.abs(this.options.Time);
        this.Auto = !!this.options.Auto;
        this.ClassOn = this.options.ClassOn;
        this.ClassOff = this.options.ClassOff;
        
        this.Set();
    },
  
    //设置默认属性
    SetOptions: function(options) 
    {
        this.options = {//默认值
            ClassOn:"",//显示时样式
            ClassOff: "",//不显示时样式
            Auto: true,//是否自动切换
            Time: 3000//切换时间
        };
        
        Object.extend(this.options, options || {});
    },
    
  //设置
    Set: function() {
        this.Each(function(list, i)
        {
            var oThis = this, img = document.createElement("img");
            
            img.src = list["img"];
            img.alt = list["text"];
            img.width="300px";
            img.height="228px";
            img.border="0px";
            img.onmouseover = function(){ oThis.Show(i);};        
            img.onmouseout = function(){ if(oThis.Auto){ oThis._timer = setTimeout(function(){ oThis.Run(); }, oThis.Time); } };
        
            this._list[i]["obj"] = img;
        
            //这里封装的不好
            this._oList.appendChild(img);
        });
    
        this.Run();
    },
    
    //显示
    Show: function(i) {
        this.Stop();
        
        if(i < 0 || i >= this._list.length) i = 0;

        if(isIE){
            this._img.filters.revealTrans.Transition = Math.floor(Math.random() * 23);
            this._img.filters.revealTrans.apply();
            this._img.filters.revealTrans.play();
        }
    
        this._img.src = this._list[i]["img"];
        this._img.alt = this._list[i]["text"];
        
        if(!this._list[i]["url"]){
            this._oText.innerHTML = this._list[i]["text"];
            this._a.removeAttribute("href");
        } else {
            this._oText.innerHTML= "<a href='" + this._list[i]["url"] + "' target='_blank'>" + this._list[i]["text"] + "</a>";
            this._a.href = this._list[i]["url"];
        }
        
        if(this._index >= 0) this._list[this._index]["obj"].className = this.ClassOff;
        
        this._list[i]["obj"].className = this.ClassOn;
        this._index = i;
        
        for(var j=1;j<=6;j++)
            document.getElementById("flashImg"+j).className="flashAIndex";
        
        document.getElementById("flashImg"+(i+1)).className="flashAIndexCurrent";
    },
      
    //开始
    Run: function() {
        this.Show(this._index + 1);
        if(this.Auto){ var oThis = this; this._timer = setTimeout(function(){ oThis.Run(); }, oThis.Time); }
    },
  
    //停止
    Stop: function() {
        clearTimeout(this._timer);
    },
  
    //
    Each:function(fun) {
        for (var i = 0, len = this._list.length; i < len; i++)
            fun.call(this, this._list[i], i);
    },
  
    //添加
    Add:function(img, text, url) {
        this.Stop();
        var len = this._list.length;
        this._list[len] = {'img': img, 'text': text, 'url': url }
        this._oList.innerHTML = "";

        this.Set();
    },
  
    //
    Delete:function(index) {
        index--;
        if(index < 0 || index > this._list.length) return;

        this.Stop();
        var _arr = [];
        var m =0;

        this.Each(function(list, i){ if(i != index) _arr[m++] = list; });
        this._list = _arr;
        this._oList.innerHTML = "";

        this.Set();
    }
};
</script>
<input type="hidden" id="hidDIDs" runat="server" /><input type="hidden" id="hidAlts" runat="server" />
<input type="hidden" id="hidImgSrc1" runat="server" /><input type="hidden" id="hidImgSrc2" runat="server" />
<input type="hidden" id="hidImgSrc3" runat="server" /><input type="hidden" id="hidImgSrc4" runat="server" />
<input type="hidden" id="hidImgSrc5" runat="server" />
<input type="hidden" id="hidImgSrc6" runat="server" />
<div id="idPicShow" style="width:300px; height:228px; position:relative;">
    <div style="height:12px;width:160px;right:3px;bottom:7px;z-index:9; position:absolute; ">
        <span id="flashImg1" class="flashAIndexCurrent">1</span>
        <span id="flashImg2" class="flashAIndex">2</span>
        <span id="flashImg3" class="flashAIndex">3</span>
        <span id="flashImg4" class="flashAIndex">4</span>
        <span id="flashImg5" class="flashAIndex">5</span>
         <span id="flashImg6" class="flashAIndex">6</span>
    </div>    
</div>
<div id="idPicText" style="display:none;"></div>
<div id="idPicList" style="display:none;"></div>

<script type="text/javascript">
var imgsrc1='<%=hidImgSrc1.ClientID %>',imgsrc2='<%=hidImgSrc2.ClientID %>';
var imgsrc3 = '<%=hidImgSrc3.ClientID %>', imgsrc4 = '<%=hidImgSrc4.ClientID %>', imgsrc5 = '<%=hidImgSrc5.ClientID %>';
var imgsrc6 = '<%=hidImgSrc6.ClientID %>';

var text1 = "图片1", text2 = "图片2", text3 = "图片3", text4 = "图片4", text5 = "图片5", text6 = "图片6";
var textE = '<%=hidAlts.ClientID %>';
var infos = document.getElementById(textE).value.split("$$");
if(infos && infos.length>0){
    text1 = infos[0]; text2 = infos[1]; text3 = infos[2]; text4 = infos[3]; text5 = infos[4]; text6 = infos[5]
}

var url1="",url2="",url3="",url4="",url5="",url6="";
var urlE = '<%=hidDIDs.ClientID %>';
var dids = document.getElementById(urlE).value.split(";");
if(dids && dids.length>0){
    var baseUrl = '<%=UrlBase %>';
    if (url1 != "") { url1 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[0]; } else { url1 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }
    if (url2 != "") { url2 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[1]; } else { url2 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }
    if (url3 != "") { url3 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[2]; } else { url3 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }
    if (url4 != "") { url4 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[3]; } else { url4 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }
    if (url5 != "") { url5 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[4]; } else { url5 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }
    if (url6 != "") { url6 = baseUrl + "/view/InfoBrowseView.aspx?pid=0&did=" + dids[5]; } else { url6 = baseUrl + "/view/InfoListView.aspx?t=jftp"; }

    
}
            
var tv = new TransView([ 
        {'img':document.getElementById(imgsrc1).value, 'text':text1, 'url':url1},
        {'img':document.getElementById(imgsrc2).value, 'text':text2, 'url':url2},
        {'img':document.getElementById(imgsrc3).value, 'text':text3, 'url':url3},
        {'img':document.getElementById(imgsrc4).value, 'text':text4, 'url':url4},
        { 'img': document.getElementById(imgsrc5).value, 'text': text5, 'url': url5 },
        { 'img': document.getElementById(imgsrc6).value, 'text': text6, 'url': url6 }
    ], "idPicShow", "idPicList", "idPicText", { ClassOn: "on" });

function Add(){
    tv.Add($("textImg").value, $("textText").value, $("textUrl").value);
}

function Delete(i){
    var i = $("textIndex").value;
    if(!isNaN(i)) tv.Delete(parseInt(i));
}
</script>